package com.link.wseller.mapper;

import com.link.wseller.domain.OrderMaster;
import org.apache.ibatis.jdbc.SQL;

public class OrderMasterSqlProvider {

    public String insertSelective(OrderMaster record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("order_master");
        
        if (record.getOrderId() != null) {
            sql.VALUES("order_id", "#{orderId,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerName() != null) {
            sql.VALUES("buyer_name", "#{buyerName,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerPhone() != null) {
            sql.VALUES("buyer_phone", "#{buyerPhone,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerAddress() != null) {
            sql.VALUES("buyer_address", "#{buyerAddress,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerOpenid() != null) {
            sql.VALUES("buyer_openid", "#{buyerOpenid,jdbcType=VARCHAR}");
        }
        
        if (record.getOrderAmount() != null) {
            sql.VALUES("order_amount", "#{orderAmount,jdbcType=DECIMAL}");
        }
        
        if (record.getOrderStatus() != null) {
            sql.VALUES("order_status", "#{orderStatus,jdbcType=TINYINT}");
        }
        
        if (record.getPayStatus() != null) {
            sql.VALUES("pay_status", "#{payStatus,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(OrderMaster record) {
        SQL sql = new SQL();
        sql.UPDATE("order_master");
        
        if (record.getBuyerName() != null) {
            sql.SET("buyer_name = #{buyerName,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerPhone() != null) {
            sql.SET("buyer_phone = #{buyerPhone,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerAddress() != null) {
            sql.SET("buyer_address = #{buyerAddress,jdbcType=VARCHAR}");
        }
        
        if (record.getBuyerOpenid() != null) {
            sql.SET("buyer_openid = #{buyerOpenid,jdbcType=VARCHAR}");
        }
        
        if (record.getOrderAmount() != null) {
            sql.SET("order_amount = #{orderAmount,jdbcType=DECIMAL}");
        }
        
        if (record.getOrderStatus() != null) {
            sql.SET("order_status = #{orderStatus,jdbcType=TINYINT}");
        }
        
        if (record.getPayStatus() != null) {
            sql.SET("pay_status = #{payStatus,jdbcType=TINYINT}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("order_id = #{orderId,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}